package com.ruoyi.huoyun.message.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.huoyun.message.domain.ToDriverEvaluate;
import com.ruoyi.huoyun.message.service.IToDriverEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对司机的评价Controller
 *
 * @author mj
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/message/toDriver")
public class ToDriverEvaluateController extends BaseController
{
    @Autowired
    private IToDriverEvaluateService toDriverEvaluateService;

    /**
     * 查询对司机的评价列表
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:list')")
    @GetMapping("/list")
    public TableDataInfo list(ToDriverEvaluate toDriverEvaluate)
    {
        startPage();
        List<ToDriverEvaluate> list = toDriverEvaluateService.selectToDriverEvaluateList(toDriverEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出对司机的评价列表
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:export')")
    @Log(title = "对司机的评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ToDriverEvaluate toDriverEvaluate)
    {
        List<ToDriverEvaluate> list = toDriverEvaluateService.selectToDriverEvaluateList(toDriverEvaluate);
        ExcelUtil<ToDriverEvaluate> util = new ExcelUtil<ToDriverEvaluate>(ToDriverEvaluate.class);
        util.exportExcel(response, list, "对司机的评价数据");
    }

    /**
     * 获取对司机的评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(toDriverEvaluateService.selectToDriverEvaluateById(id));
    }

    /**
     * 新增对司机的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:add')")
    @Log(title = "对司机的评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ToDriverEvaluate toDriverEvaluate)
    {
        return toAjax(toDriverEvaluateService.insertToDriverEvaluate(toDriverEvaluate));
    }

    /**
     * 修改对司机的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:edit')")
    @Log(title = "对司机的评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ToDriverEvaluate toDriverEvaluate)
    {
        return toAjax(toDriverEvaluateService.updateToDriverEvaluate(toDriverEvaluate));
    }

    /**
     * 删除对司机的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toDriver:remove')")
    @Log(title = "对司机的评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(toDriverEvaluateService.deleteToDriverEvaluateByIds(ids));
    }
}
